package com.wyj.session;

import com.wyj.config.XMLConfigBuilder;
import com.wyj.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @author wuyijie
 * @description: TODO 生产SqlSessionFactory对象
 * @date 2021/10/30 10:37 上午
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(InputStream inputStream) throws PropertyVetoException, DocumentException, ClassNotFoundException {
        // 1、创建configuration
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        // 2、创建sqlSessionFactory
        return new DefaultSqlSessionFactory(configuration);
    }
}
